package com.neusoft.service.impl;

import com.neusoft.mapper.FoodMapper;
import com.neusoft.po.Food;
import com.neusoft.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {

    @Autowired
    private FoodMapper foodMapper;

    @Override
    public List<Food> listFoodByBusinessId(Integer businessId) {
        return foodMapper.listFoodByBusinessId(businessId);
    }

//    @Override
//    public Food getFoodByFoodId(Integer foodId) {
//        return foodMapper.getFoodByFoodId(foodId);
//    }

    @Transactional
    public int saveFood(Integer businessId, String foodName, String foodExplain, Double foodPrice) {
        return foodMapper.saveFood(businessId, foodName, foodExplain, foodPrice);
    }
    @Override
    public int updateFood(Integer foodId,Integer businessId, String foodName, String foodExplain, Double foodPrice, String foodImg) {
        return foodMapper.updateFood(foodId,businessId, foodName, foodExplain, foodPrice, foodImg);
    }

    @Override
    public int removeFood(Integer businessId, Integer foodId) {
        return foodMapper.removeFood(businessId, foodId);
    }
    @Override
    public Food getFoodById(Integer foodId, Integer businessId) {
        return foodMapper.getById(foodId, businessId);
    }
    @Override
    public Food getById(Integer foodId) {
        return foodMapper.getFoodById(foodId);
    }
}
